GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( cdb95b...a04e84 )
by Vladimir
29s
created

socket.log   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 9
rs 9.6666
1
/** global: io */
2
var socket = io.connect();
3
var streamId = window.location.pathname.substring(1);
4
var autoScrool = true;
5
6
/**
7
 * Gets element with log message data.
8
 *
9
 * @param {String} data Log message data.
10
 */
11
function getCodeElement(data) {
12
  var c = document.createElement('code');
13
  c.className = 'code blink hljs json';
14
  c.innerHTML = JSON.stringify(data, null, "\t");
15
  /** global: hljs */
16
  hljs.highlightBlock(c);
17
18
  var pre = document.createElement('pre');
19
  pre.appendChild(c);
20
21
  return pre;
22
}
23
24
/**
25
 * Gets element with ip address.
26
 *
27
 * @param {String} ip Ip address.
28
 */
29
function getIpElement(ip) {
30
  var s = document.createElement('span');
31
  s.className = 'ip';
32
  s.innerHTML = ip;
33
34
  return s;
35
}
36
37
/**
38
 * Gets element with current date.
39
 */
40
function getDateElement() {
41
  var s = document.createElement('span');
42
  s.className = 'date';
43
  s.innerHTML = (new Date()).toLocaleDateString(
44
    'en-GB',
45
    {hour: '2-digit', minute: '2-digit', second: '2-digit'}
46
  );
47
48
  return s;
49
}
50
51
/**
52
 * Gets element with tags content.
53
 *
54
 * @param {Object} data LOG.NEW payload.
55
 */
56
function getTags(data) {
57
  var d = document.createElement('div');
58
  d.className = 'tags';
59
  d.appendChild(getDateElement());
60
  d.appendChild(getIpElement(data.ip));
61
62
  return d;
63
}
64
65
/**
66
 * Renders new log message.
67
 *
68
 * @param {Object} data LOG.NEW payload.
69
 */
70
function renderJson(data) {
71
  var p = document.createElement('p');
72
  p.appendChild(getTags(data));
73
  p.appendChild(getCodeElement(data.data));
74
  document.getElementById('root').appendChild(p);
75
76
  if (autoScrool === true) {
77
    window.scrollTo(0, document.body.scrollHeight);
78
  }
79
}
80
81
/**
82
 * Auto-scrolling to latest data.
83
 */
84
window.onscroll = function() {
85
  autoScrool = (
86
    (window.innerHeight + window.scrollY) >= document.body.offsetHeight
87
  );
88
};
89
90
/**
91
 * Handler for new data.
92
 * Renders data on web page (add to the bottom).
93
 *
94
 * @event LOG.NEW
95
 */
96
socket.on('log', function(data) {
97
  if (data.streamId !== streamId) {
98
    return;
99
  }
100
  if (data.format === 'json') {
101
    return renderJson(data);
102
  }
103
  console.error('Got unsupported format: %s', data.format);
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
104
});
105